package com.pi.controller;

import com.pi.dao.PublishDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.Map;

public class PublishGetUrl extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Map<String,String[]> map=req.getParameterMap();
        boolean success=false;
        try {
            success=new PublishDao().insertData(map);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        if(success){
            resp.setContentType("text/html;charset=utf-8");
            PrintWriter writer=resp.getWriter();
            writer.println("http://47.100.105.127:8080/pi/fill?user_id="+ map.get("user_id")[0]+
                    "&user_report_id="+map.get("user_report_id")[0]+
                    "&report_column_number="+map.get("report_column_number")[0]);
            writer.flush();
            writer.close();
        }
    }
}
